import store from '@/store';
import { ref } from 'vue';
import defaultSettings from '@/config/defaultSettings';
import api from '@/api';
export const useFeishu = () => {
    const isLoginFeishu = ref<any>(false);
    // 判断是否登陆过
    const checkLoginFeishu = async () => {
        const { success, moule } = await api.uacModel.getAccountInfo();
        if (success) {
            if (moule.accountStatus !== '未登录') {
                isLoginFeishu.value = true;
                return true;
            } else {
                isLoginFeishu.value = false;
                return false;
            }
        }
    };
    const loginFeishu = () => {
        const { production } = defaultSettings;
        const { hostname } = document.location;
        const ip = production ? `${hostname}:20018` : '10.141.51.6:20018';
        let appId = 'cli_a384732ec7bed00e';
        if (hostname === '10.142.14.27') {
            appId = 'cli_a386df3daff8500e';
        }
        window.open(`https://open.feishu.cn/open-apis/authen/v1/index?redirect_uri=http://${ip}/tool/feishu&app_id=${appId}&state=zzkTest`);
    };
    return {
        isLoginFeishu,
        checkLoginFeishu,
        loginFeishu
    };
};